/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package colordrips;

import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
import javax.swing.ImageIcon;

/**
 * Formulário da tela principal do jogo.
 * @author SimaoItalo
 */
public class HomeScreen extends javax.swing.JFrame implements MouseListener{

    PlayingField field;
    
    /**
     * Construtor do formulário.
     */
    public HomeScreen() {
        initComponents();
        addMouseListenersOnButtons();
    }
    
    /**
     * Adiciona os eventos de mouse nos labels do menu.
     */
    private void addMouseListenersOnButtons(){
        lbRanking.addMouseListener(this);
        lbIniciarJogo.addMouseListener(this);
        lbRegras.addMouseListener(this);
    }

    /**
     * This method is called from within the constructor to initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is always
     * regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        lbRanking = new javax.swing.JLabel();
        lbIniciarJogo = new javax.swing.JLabel();
        lbRegras = new javax.swing.JLabel();
        lbBackGround = new javax.swing.JLabel();

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
        setTitle("ColorDrips");
        setCursor(new java.awt.Cursor(java.awt.Cursor.DEFAULT_CURSOR));
        setMinimumSize(new java.awt.Dimension(628, 496));
        setResizable(false);
        getContentPane().setLayout(new org.netbeans.lib.awtextra.AbsoluteLayout());

        lbRanking.setIcon(new javax.swing.ImageIcon(getClass().getResource("/assets/botao_rank.png"))); // NOI18N
        getContentPane().add(lbRanking, new org.netbeans.lib.awtextra.AbsoluteConstraints(220, 210, 190, 40));

        lbIniciarJogo.setIcon(new javax.swing.ImageIcon(getClass().getResource("/assets/botao_iniciarJogo.png"))); // NOI18N
        getContentPane().add(lbIniciarJogo, new org.netbeans.lib.awtextra.AbsoluteConstraints(220, 150, 190, 40));

        lbRegras.setIcon(new javax.swing.ImageIcon(getClass().getResource("/assets/botao_regras.png"))); // NOI18N
        getContentPane().add(lbRegras, new org.netbeans.lib.awtextra.AbsoluteConstraints(220, 270, 190, 40));

        lbBackGround.setIcon(new javax.swing.ImageIcon(getClass().getResource("/assets/bg3.png"))); // NOI18N
        getContentPane().add(lbBackGround, new org.netbeans.lib.awtextra.AbsoluteConstraints(0, 0, -1, 500));

        pack();
    }// </editor-fold>//GEN-END:initComponents

    /**
     * @param args the command line arguments
     */
    public static void main(String args[]) {
        /* Set the Nimbus look and feel */
        //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
        /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
         * For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html 
         */
        try {
            for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
                if ("Nimbus".equals(info.getName())) {
                    javax.swing.UIManager.setLookAndFeel(info.getClassName());
                    break;
                }
            }
        } catch (ClassNotFoundException ex) {
            java.util.logging.Logger.getLogger(HomeScreen.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (InstantiationException ex) {
            java.util.logging.Logger.getLogger(HomeScreen.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (IllegalAccessException ex) {
            java.util.logging.Logger.getLogger(HomeScreen.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (javax.swing.UnsupportedLookAndFeelException ex) {
            java.util.logging.Logger.getLogger(HomeScreen.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        }
        //</editor-fold>

        /* Create and display the form */
        java.awt.EventQueue.invokeLater(new Runnable() {
            public void run() {
                new HomeScreen().setVisible(true);
            }
        });
    }
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JLabel lbBackGround;
    private javax.swing.JLabel lbIniciarJogo;
    private javax.swing.JLabel lbRanking;
    private javax.swing.JLabel lbRegras;
    // End of variables declaration//GEN-END:variables

    /**
     * Implementação do método mouseClicked.
     */
    @Override
    public void mouseClicked(MouseEvent e) {
        
    }

    /**
     * Implementação do método mousePressed.
     * Esse evento é disparado quando o botão do mouse é pressionado, muda a imagem do label selecionado.
     */
    @Override
    public void mousePressed(MouseEvent e) {
        if(e.getSource() == lbIniciarJogo){
            lbIniciarJogo.setIcon(new ImageIcon(getClass().getResource("/assets/botao_iniciarJogo_pressed.png")));
        } else if(e.getSource() == lbRanking){
            lbRanking.setIcon(new ImageIcon(getClass().getResource("/assets/botao_rank_pressed.png")));
        } else if(e.getSource() == lbRegras){
            lbRegras.setIcon(new ImageIcon(getClass().getResource("/assets/botao_regras_pressed.png")));
        }
    }

    /**
     * Implementação do método mouseReleased.
     * Esse evento é disparado quando o botão do mouse é solto, muda a imagem do label selecionado.
     */
    @Override
    public void mouseReleased(MouseEvent e) {
        if(e.getSource() == lbIniciarJogo){
            lbIniciarJogo.setIcon(new ImageIcon(getClass().getResource("/assets/botao_iniciarJogo_ed.png")));
            field = new PlayingField("nomeJogador", this);
            field.setVisible(true);
            this.setVisible(false);
        } else if(e.getSource() == lbRanking){
            lbRanking.setIcon(new ImageIcon(getClass().getResource("/assets/botao_rank_ed.png")));
        } else if(e.getSource() == lbRegras){
            lbRegras.setIcon(new ImageIcon(getClass().getResource("/assets/botao_regras_ed.png")));
        }
    }

    /**
     * Implementação do método mouseEntered.
     * Esse evento é disparado quando a seta do mouse entra na área do label, muda a imagem do label selecionado.
     */
    @Override
    public void mouseEntered(MouseEvent e) {
        if(e.getSource() == lbIniciarJogo){
            lbIniciarJogo.setIcon(new ImageIcon(getClass().getResource("/assets/botao_iniciarJogo_ed.png")));
        } else if(e.getSource() == lbRanking){
            lbRanking.setIcon(new ImageIcon(getClass().getResource("/assets/botao_rank_ed.png")));
        } else if(e.getSource() == lbRegras){
            lbRegras.setIcon(new ImageIcon(getClass().getResource("/assets/botao_regras_ed.png")));
        }
    }

    /**
     * Implementação do método mouseReleased.
     * Esse evento é disparado quando a seta do mouse sai da área do label, muda a imagem do label selecionado.
     */
    @Override
    public void mouseExited(MouseEvent e) {
        if(e.getSource() == lbIniciarJogo){
            lbIniciarJogo.setIcon(new ImageIcon(getClass().getResource("/assets/botao_iniciarJogo.png")));
        } else if(e.getSource() == lbRanking){
            lbRanking.setIcon(new ImageIcon(getClass().getResource("/assets/botao_rank.png")));
        } else if(e.getSource() == lbRegras){
            lbRegras.setIcon(new ImageIcon(getClass().getResource("/assets/botao_regras.png")));
        }
    }
}
